<?php
/**
 * RedCross Application
 *
 * @copyright Copyright (c) 2010, Kristian Stokke Tryggestad, Rune Vikestad, Andreas Flaten Wist, Simen Nicolai Echholt, Ole Henrik Jahren
 */

/**
 * View & Layout resource class for Zend_Application
 *
 * @package RedCross_Application
 * @category RedCross
 */
class RedCross_Application_Resource_LayoutHelper extends Zend_Application_Resource_ResourceAbstract
{
    /**
     * Array of configuration options
     * @var array
     */
    protected $_options = array(
        'doctype'   => Zend_View_Helper_Doctype::XHTML1_STRICT,
        'encoding'  => 'UTF-8',
        'title'     => 'Site title',
        'title_separator' => ' - ',
    );

    public function init()
    {
        $bootstrap = $this->getBootstrap();
        $bootstrap->bootstrap('View');
        $view = $bootstrap->getResource('View');

        $options = $this->getOptions();

        $view->doctype($options['doctype']);
        $view->setEncoding($options['encoding']);

        $view->addHelperPath("RedCross/View/Helper", "RedCross_View_Helper");
        $view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");

        $view->headMeta()->appendHttpEquiv('Content-Type','text/html; charset=utf-8');

        $view->headTitle()->setSeparator($options['title_separator'])->append($options['title']);

        // Register View-plugin that adds stylesheets, etc.
        Zend_Controller_Front::getInstance()->registerPlugin(new RedCross_Controller_Plugin_View($view));
    }
}